﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraGrid.Editors;
using DevExpress.XtraLayout;
using DevExpress.Utils.Win;
using mendian;
using DiaoPaiDaYin;
using DevExpress.XtraGrid.Demos.util;
using Luna小店.UC.门店下单.DTO;
using Luna小店.UC.门店下单.form.标准款;
using static Luna小店.UC.门店下单.form.标准款.Frm扫码下单;
using Luna小店.service;
using Luna小店.UC.坚山;
using Luna小店.model;
using Luna小店.原型;
using Luna小店.Utils;
using System.Diagnostics;
using Luna小店.DTO.尖山;
using System.IO;
using Luna小店.UC.销售记录.service;
using Luna小店.DTO;

namespace Luna小店.UC.门店下单.form
{
    public partial class Frm坚山订单创建 : DevExpress.XtraEditors.XtraForm
    {

        /// <summary>
        /// 订单充血类
        /// </summary>
        private OrderModel orderModel = new OrderModel();

        public enum Enum下单类型 { 服装定制下单, 标准款扫码下单, 标准款无码下单 };

        public Frm坚山订单创建()
        {
            //String str = FileService.UploadRequest("http://192.168.6.223:8090/mail/sendSimpleMail", @"C:\Users\Doge\Desktop\20.6.1.xlsx", "20.6.1.xlsx");
            //FileService.ExcelAddOrderNo("", "20.6.1", @"C:\Users\Doge\Desktop\20.6.1.xlsx");
            InitializeComponent();
            //this.initData();    //  测试方法
            this.gridControl订单分录一览.DataSource = this.orderModel.OrderDtos;
            //this.textEdit订单号.Text = FunctionHelper.generateBillNo(
            //    "t_shop_order", "order_code", "SALE", "00000"
            //    );// TODO，单号
            this.textEdit订单号.Text = FunctionHelper.generateBillNo_坚山("o_order_p", "ORDER_NO", "KA.DL27.", "000000");
            this.comboBox店铺.SelectedIndex = 0;
        }

        /// <summary>
        /// 新增分录
        /// </summary>
        public void buildOrderModel(Dto定制下单 dto定制下单)
        {
            this.orderModel.buildAddOrderDtos(dto定制下单);
        }

        private void Frm门店统一下单_Load(object sender, EventArgs e)
        {
            this.searchLookUpEdit1.Properties.DataSource = CustomerService.GetCustomerData("","46");
        }
        #region 选择客户
        private void searchLookUpEdit1_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }

        private void searchLookUpEdit1View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit1.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                Frm客户.cUSTOMER_ID //  no
                    = Convert.ToInt32(this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "ID").ToString());//id 是 Value Member
                Frm客户.customer_name //  no
                    = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "客户姓名").ToString();//id 是 Value Member
            }
            DataTable dt = SQLmtm.GetDataTable("SELECT * FROM (SELECT * FROM a_customer_fit_r) s1 RIGHT JOIN (SELECT * FROM a_customer_fit_count_r WHERE CUSTOMER_ID ='" + Frm客户.cUSTOMER_ID + "' AND DEFAULT_FLAG ='1') s2 on s1.FIT_COUNT_ID=s2.ID");
            if (dt.Rows.Count != 0)
            {
                DataRow drr = SQLmtm.GetDataRow("SELECT * FROM `a_customer_fit_count_r` WHERE CUSTOMER_ID='" + Frm客户.cUSTOMER_ID.ToString() + "' AND DEFAULT_FLAG=1");
                DataRow ddr = SQLmtm.GetDataRow("SELECT * FROM `a_customer_address_p` WHERE CUSTOMER_ID='" + Frm客户.cUSTOMER_ID.ToString() + "'");
                if (drr == null || ddr == null)
                {
                    Frm客户.cUSTOMER_ID = 0;
                    Frm客户.customer_name = "";
                    MessageBox.Show("缺少客户信息");
                    return;
                }
                Frm客户.customer_countid = Convert.ToInt32(drr["ID"]);
                //Frm客户.aDDRESS_ID = Convert.ToInt32(ddr["ADDRESS_ID"]);
                Frm客户.aDDRESS_ID = 0;
            }
            else
            {
                Frm客户.customer_countid = 0;
                //Frm客户.cUSTOMER_ID = 0;
                //Frm客户.customer_name = "";
                //MessageBox.Show("选择的客户未建立量体值");
            }
            this.gridControl2.DataSource = CustomerService.GetCustomerInformation(Frm客户.cUSTOMER_ID);
            this.orderModel = new OrderModel();
            this.show设计点("0");
            this.refreshGridControl();
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit1.ToolTip = null;
            searchLookUpEdit1.EditValue = null;
        }
        private void searchLookUpEdit1_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = Frm客户.customer_name;
        }
        #endregion

        private void tileBarItem1_ItemClick(object sender, TileItemEventArgs e)
        {
            //new Frm门店下单选款式(this, Enum下单类型.服装定制下单).ShowDialog();
            new Frm坚山创建款式(this).ShowDialog();
        }

        private void tileBarItem6_ItemClick(object sender, TileItemEventArgs e)
        {
            //new Frm门店下单选款式(this, Enum下单类型.标准款无码下单).ShowDialog();
        }

        public void refreshGridControl()
        {
            this.gridControl订单分录一览.DataSource = this.orderModel.OrderDtos;
            this.tileView1.RefreshData();
        }

        private void tileBarItem2_ItemClick(object sender, TileItemEventArgs e)
        {
            new Frm扫码下单(Enum进出库类型.出库).ShowDialog();
        }


        private void tileView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            String ID = (String)tileView1.GetRowCellValue(e.FocusedRowHandle, "ID");
            this.show设计点(ID);
        }

        private void tileView1_ItemClick(object sender, DevExpress.XtraGrid.Views.Tile.TileViewItemClickEventArgs e)
        {
            String ID = (String)tileView1.GetRowCellValue(e.Item.RowHandle, "ID");
            this.show设计点(ID);
        }

        private void show设计点(String ID)
        {
            DataRow dataRow = this.tileView1.GetDataRow(this.tileView1.FocusedRowHandle);

            List<DTODesignPoints> dto设计点s = new List<DTODesignPoints>();
            foreach (OrderDto orderDto in this.orderModel.OrderDtos)
            {
                if (ID.Equals(orderDto.id))
                {
                    dto设计点s = orderDto.dtoDesignPoints;
                    break;
                }
            }
            this.gridControl设计点.DataSource = dto设计点s;
            this.tileView1.RefreshData();
        }

        private void siveorder_Click(object sender, EventArgs e)
        {
            this.splashScreenManager.ShowWaitForm();
            this.splashScreenManager.SetWaitFormCaption("请稍后,正在加载中....");     // 标题
            this.splashScreenManager.SetWaitFormDescription("正在初始化.....");     // 信息
            if (Frm客户.aDDRESS_ID != 4979 && Frm客户.aDDRESS_ID != 4981 && Frm客户.aDDRESS_ID != 4983)
            {
                MessageBox.Show("请选择店铺");
                this.splashScreenManager.CloseWaitForm();
                return;
            }
            if (String.IsNullOrEmpty(this.comboBox店铺.Text))
            {
                MessageBox.Show("请选择店铺");
                this.splashScreenManager.CloseWaitForm();
                return;
            }
            if (Frm客户.cUSTOMER_ID == 0)
            {
                MessageBox.Show("客户为空,请选择客户");
                this.splashScreenManager.CloseWaitForm();
                return;
            }
            try
            {
                if (comboBox店铺.Text.Equals("日本"))
                {
                    this.orderModel.SaveOrderInDatabase();
                }
                else if (comboBox店铺.Text.Equals("美国"))
                {
                    this.orderModel.SaveOrderInDatabase();
                }
                this.splashScreenManager.CloseWaitForm();
                MessageBox.Show("保存成功");

            }
            catch (Exception ex)
            {
                this.splashScreenManager.CloseWaitForm();
                MessageBox.Show(ex.Message);
            }



        }

        private void tileBarItem5_ItemClick(object sender, TileItemEventArgs e)
        {
            new Frm客户("46").ShowDialog();
            Frm客户.cUSTOMER_ID = 0;
            Frm客户.customer_name = "";
            Frm客户.customer_countid = 0;
            Frm客户.aDDRESS_ID = 0;
            this.searchLookUpEdit1.Properties.DataSource = CustomerService.GetCustomerData("","46");
        }

        private void tileBarItem4_ItemClick(object sender, TileItemEventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            ExcelAndPath excelAndPath = ExcelUtil.getExcelDatasAndPath();
            if (excelAndPath == null)
            {
                return;
            }
            DataSet result = excelAndPath.DataSet;
            //
            this.splashScreenManager.ShowWaitForm();
            this.splashScreenManager.SetWaitFormCaption("请稍后,正在加载中....");     // 标题
            this.splashScreenManager.SetWaitFormDescription("正在初始化.....");     // 信息
            #region 取尺寸
            DataTable dataTableHDHF = result.Tables["Measurements HD HF"];
            DTOMeasurements dTOMeasurementsHDHF = new DTOMeasurements("HDHF", dataTableHDHF.Rows[14]["Column1"].ToString(), dataTableHDHF);
            //Dictionary<String, String> HDHF测量 = new Dictionary<string, string>();
            //for (int i = 16; i <= 27; i++)
            //{
            //    HDHF测量.Add(dataTableHDHF.Rows[i]["Column0"].ToString(), dataTableHDHF.Rows[i]["Column5"].ToString());
            //}
            ////HDHF尺寸
            //DTOMeasurementsHDHF dTOMeasurementsHDHF = new DTOMeasurementsHDHF(dataTableHDHF.Rows[14]["Column1"].ToString(), HDHF测量);
            DataTable dataTableHH = result.Tables["Measurements HH"];
            DTOMeasurements dTOMeasurementsHH = new DTOMeasurements("HH", dataTableHH.Rows[14]["Column1"].ToString(), dataTableHH);
            //Dictionary<String, String> HH测量 = new Dictionary<string, string>();
            //for (int i = 16; i <= 27; i++)
            //{
            //    HH测量.Add(dataTableHH.Rows[i]["Column0"].ToString(), dataTableHH.Rows[i]["Column5"].ToString());
            //}
            ////HH测量.Add(dataTableHH.Rows[24]["Column0"].ToString(), dataTableHH.Rows[24]["Column5"].ToString());
            ////HH测量.Add(dataTableHH.Rows[25]["Column0"].ToString(), dataTableHH.Rows[25]["Column5"].ToString());
            ////HH尺寸
            //DTOMeasurementsHH dTOMeasurementsHH = new DTOMeasurementsHH(dataTableHH.Rows[14]["Column1"].ToString(), HH测量);
            #endregion
            String firstName = "";
            String lastName = "";
            for (int i = 0; i < result.Tables.Count; i++)
            {
                if (!result.Tables[i].TableName.Contains("Measurements"))
                {
                    DataTable 订单页 = result.Tables[i];
                    Dictionary<String, String> 设计点 = new Dictionary<string, string>();
                    for (int i1 = 9; i1 <= 23; i1++)
                    {
                        设计点.Add(订单页.Rows[i1]["Column0"].ToString(), 订单页.Rows[i1]["Column1"].ToString());
                    }
                    设计点.Add(订单页.Rows[25]["Column0"].ToString(), 订单页.Rows[25]["Column1"].ToString());
                    设计点.Add(订单页.Rows[26]["Column0"].ToString(), 订单页.Rows[26]["Column1"].ToString());
                    String[] Name = 订单页.Rows[3]["Column0"].ToString().Split(' ');
                    String Fname = Name[0];
                    String Lname = "";
                    try
                    {
                        Lname = Name[1];
                    }
                    catch { }
                    //订单页
                    DTO订单页 dTO订单页 = new DTO订单页(订单页.Rows[7]["Column0"].ToString(), 订单页.Rows[7]["Column1"].ToString(), 设计点).buildCustomer(Fname, Lname);
                    //充血
                    this.orderModel.OrderDtos.Add(new OrderDto().build订单fromExcel(dTO订单页, dTOMeasurementsHDHF, dTOMeasurementsHH).build坚山美国回执数据(订单页, 订单页.TableName).buildkashiyamaOrderNo(订单页.Rows[1]["Column2"].ToString()).build订单类型(Enum订单类型.坚山美国Excel导入订单));
                    firstName = dTO订单页.firstName;
                    lastName = dTO订单页.lastName;
                }
                else
                {

                }
            }
            CustomerService.Create坚山美国Customer(firstName, lastName);
            //存入数据库
            //this.orderModel.SaveOrderInDatabase();
            this.orderModel.buildCustomer();
            //新保存接口
            DTO销售记录 DTO销售记录 = new DTO销售记录().buildForKashiyamaUS(orderModel.OrderDtos);
            String jsonDTO销售记录 = FunctionHelper.JsonSerialization(DTO销售记录);
            RestCall.PostHttp(URL.接口url + "/barcode/saveOrder_KASHIYAMAUS", FunctionHelper.JsonSerialization(DTO销售记录));

            #region 老代码
            //DataTable testHD = result.Tables["Sample 0-0013"];
            //Dictionary<String, String> HD设计点 = new Dictionary<string, string>();
            //for (int i = 9; i <= 23; i++)
            //{
            //    HD设计点.Add(testHD.Rows[i]["Column0"].ToString(), testHD.Rows[i]["Column1"].ToString());
            //}
            //HD设计点.Add(testHD.Rows[25]["Column0"].ToString(), testHD.Rows[25]["Column1"].ToString());
            //HD设计点.Add(testHD.Rows[26]["Column0"].ToString(), testHD.Rows[26]["Column1"].ToString());
            //String[] Name = testHD.Rows[3]["Column0"].ToString().Split(' ');
            //String fname = Name[0];
            //String lname = "";
            //try
            //{
            //    lname = Name[1];
            //}
            //catch { }
            ////HD设计点面料
            //DTOTest dTOTestHD = new DTOTest(testHD.Rows[7]["Column0"].ToString(), testHD.Rows[7]["Column1"].ToString(), HD设计点).buildCustomer(fname, lname);

            /*
            DataTable testHF = result.Tables["Sample 0-0014"];
            Dictionary<String, String> HF设计点 = new Dictionary<string, string>();
            for (int i = 9; i <= 23; i++)
            {
                HF设计点.Add(testHF.Rows[i]["Column0"].ToString(), testHF.Rows[i]["Column1"].ToString());
            }
            HF设计点.Add(testHF.Rows[25]["Column0"].ToString(), testHF.Rows[25]["Column1"].ToString());
            HF设计点.Add(testHF.Rows[26]["Column0"].ToString(), testHF.Rows[26]["Column1"].ToString());
            String[] Name = testHF.Rows[3]["Column0"].ToString().Split(' ');
            String fname = Name[0];
            String lname = "";
            try
            {
                lname = Name[1];
            }
            catch { }
            //HF设计点面料
            DTOTest dTOTestHF = new DTOTest(testHF.Rows[7]["Column0"].ToString(), testHF.Rows[7]["Column1"].ToString(), HF设计点).buildCustomer(fname, lname);
            //this.orderDto.build设计点fromExcelHF(dTOTestHF.map);

            //
            DataTable dataTableHDHF = result.Tables["Measurements HD HF"];
            Dictionary<String, String> HDHF测量 = new Dictionary<string, string>();
            for (int i = 16; i <= 23; i++)
            {
                HDHF测量.Add(dataTableHDHF.Rows[i]["Column0"].ToString(), dataTableHDHF.Rows[i]["Column5"].ToString());
            }
            //HDHF尺寸
            DTOMeasurementsHDHF dTOMeasurementsHDHF = new DTOMeasurementsHDHF(dataTableHDHF.Rows[14]["Column1"].ToString(), HDHF测量);
            //充血中
            //this.orderModel.OrderDtos.Add(new OrderDto().build订单fromExcel(dTOTestHD, dTOMeasurementsHDHF, null));


            //.build坚山美国回执数据(testHD, "TEST HD"));
            this.orderModel.OrderDtos.Add(new OrderDto().build订单fromExcel(dTOTestHF, dTOMeasurementsHDHF, null));
              /* .build坚山美国回执数据(testHF, "TEST HF"));
         //
         DataTable testHH = result.Tables["TEST HH"];
         Dictionary<String, String> HH设计点 = new Dictionary<string, string>();
         for (int i = 9; i <= 23; i++)
         {
             HH设计点.Add(testHH.Rows[i]["Column0"].ToString(), testHH.Rows[i]["Column1"].ToString());
         }
         HH设计点.Add(testHH.Rows[25]["Column0"].ToString(), testHH.Rows[25]["Column1"].ToString());
         HH设计点.Add(testHH.Rows[26]["Column0"].ToString(), testHH.Rows[26]["Column1"].ToString());
         //HH设计点面料json
         DTOTest dTOTestHH = new DTOTest(testHH.Rows[7]["Column0"].ToString(), testHH.Rows[7]["Column1"].ToString(), HH设计点);

         //
         DataTable dataTableHH = result.Tables["Measurements HH"];
         Dictionary<String, String> HH测量 = new Dictionary<string, string>();
         for (int i = 14; i <= 19; i++)
         {
             HH测量.Add(dataTableHH.Rows[i]["Column0"].ToString(), dataTableHH.Rows[i]["Column5"].ToString());
         }
         HH测量.Add(dataTableHH.Rows[24]["Column0"].ToString(), dataTableHH.Rows[24]["Column5"].ToString());
         HH测量.Add(dataTableHH.Rows[25]["Column0"].ToString(), dataTableHH.Rows[25]["Column5"].ToString());
         //HH尺寸json
         DTOMeasurementsHH dTOMeasurementsHH = new DTOMeasurementsHH(dataTableHH.Rows[12]["Column1"].ToString(), HH测量);
         //充血中
         this.orderModel.OrderDtos.Add(new OrderDto().build订单fromExcel(dTOTestHH, null, dTOMeasurementsHH).build坚山美国回执数据(testHH, "TEST HH"));*/


            //CustomerService.Create坚山美国Customer(dTOTestHF.firstName, dTOTestHF.lastName);
            //String json = FunctionHelper.JsonSerialization(this.orderModel);
            ////存入数据库
            //this.orderModel.SaveOrderInDatabase(Enum订单类型.坚山美国Excel导入订单);
            #endregion

            List<坚山美国订单回执数据> dtos = new List<坚山美国订单回执数据>();
            foreach (OrderDto orderDto in this.orderModel.OrderDtos)
            {
                dtos.Add(orderDto.OrderReceiptData);
                FileService.ExcelAddOrderNo(orderDto.orderNo, orderDto.OrderReceiptData.SheetName, excelAndPath.Path + "\\" + excelAndPath.Name);

                String kOrderNo = orderDto.kashiyamaOrderNo;
                String jsonkashiyamaSizeFitDTOs = FunctionHelper.JsonSerialization(orderDto.dtoSize.kashiyamaSizeFitDTOs);

            }
            #region 串子
            String sjson = "[{\"No\":null,\"Order_No\":\"KA.DL27.461841\",\"Order_\":\"4-0020-3-1\",\"Customer_Name\":\"Quinn Quinsler\",\"Item\":\"HD\",\"Fabric_Number\":\"JM-46\",\"Order_Date\":\"2020/6/1 0:00:00\",\"Staff_Name\":\"Quinn\",\"Quantity\":\"1 of 3\",\"Email_Address\":\"quinn@onwardusa.com\",\"Mobile_Number\":\"2154095410\",\"Street_Address\":\"1430 Walnut St. Suite 200\",\"City\":\"Philadelphia\",\"State\":\"PA\",\"Zip_Code\":\"19102\",\"Color\":\"Blue/White\",\"Pattern\":\"Check\",\"Price\":\"100\",\"Option\":\"0\",\"Subtotal\":\"100\",\"Tax\":\"0\",\"Total_Price\":\"100\"},{\"No\":null,\"Order_No\":\"KA.DL27.461842\",\"Order_\":\"4-0021-3-2\",\"Customer_Name\":\"Quinn Quinsler\",\"Item\":\"HF\",\"Fabric_Number\":\"JM-46\",\"Order_Date\":\"2020/6/1 0:00:00\",\"Staff_Name\":\"Quinn\",\"Quantity\":\"2 of 3\",\"Email_Address\":\"quinn@onwardusa.com\",\"Mobile_Number\":\"2154095410\",\"Street_Address\":\"1430 Walnut St. Suite 200\",\"City\":\"Philadelphia\",\"State\":\"PA\",\"Zip_Code\":\"19102\",\"Color\":\"Blue/White\",\"Pattern\":\"Check\",\"Price\":\"130\",\"Option\":\"0\",\"Subtotal\":\"130\",\"Tax\":\"0\",\"Total_Price\":\"130\"},{\"No\":null,\"Order_No\":\"KA.DL27.461843\",\"Order_\":\"4-0022-3-3\",\"Customer_Name\":\"Quinn Quinsler\",\"Item\":\"HH\",\"Fabric_Number\":\"JM-46\",\"Order_Date\":\"2020/6/1 0:00:00\",\"Staff_Name\":\"Quinn\",\"Quantity\":\"3 of 3\",\"Email_Address\":\"quinn@onwardusa.com\",\"Mobile_Number\":\"2154095410\",\"Street_Address\":\"1430 Walnut St. Suite 200\",\"City\":\"Philadelphia\",\"State\":\"PA\",\"Zip_Code\":\"19102\",\"Color\":\"Blue/White\",\"Pattern\":\"Check\",\"Price\":\"100\",\"Option\":\"0\",\"Subtotal\":\"100\",\"Tax\":\"\",\"Total_Price\":\"100\"}]";
            #endregion
            //dtos = FunctionHelper.JsonDeserialization<List<坚山美国订单回执数据>>(sjson);
            if (!Directory.Exists(@"KaShiYaMaUSExcel"))
            {
                Directory.CreateDirectory(@"KaShiYaMaUSExcel");
            }
            else
            {
                //Directory.Delete(@"KaShiYaMaUSExcel");
            }
            String path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "KaShiYaMaUSExcel\\";
            FileInfo file = new FileInfo(excelAndPath.Path + "\\" + excelAndPath.Name);
            String name = DateTime.Now.Year.ToString() + "." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + "." + DateTime.Now.Hour.ToString() + "." + DateTime.Now.Minute.ToString();
            file.CopyTo(path + name + excelAndPath.Name);
            FileService.SaveDataToExcelFile(dtos, path + name + ".xls");
            //FileService.CondenseRarOrZip(path + name + ".xls", path + name + ".rar", true, "");
            //FileService.RAR(path + name + ".xls", path + name + ".rar", name + ".rar");
            //FileService.CompressRar(path + name + ".xls", path + name + ".rar");
            //FileService.UploadRequest("http://192.168.6.223:8090/mail/sendSimpleMail", path + name + ".rar", name + ".rar");
            //File.Delete(path + name + ".xls");
            //File.Delete(path + name + ".rar");
            stopWatch.Stop();
            System.Diagnostics.Debug.WriteLine("Excel导入订单时间" + stopWatch.ElapsedMilliseconds + " ms.");
            this.splashScreenManager.CloseWaitForm();
            MessageBox.Show("下单成功");
        }

        private void comboBox门店_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (this.comboBox门店.SelectedItem)
            {
                case "森茂":
                    Frm客户.aDDRESS_ID = 4979;
                    break;
                case "成大":
                    Frm客户.aDDRESS_ID = 4981;
                    break;
                case "开发区":
                    Frm客户.aDDRESS_ID = 4983;
                    break;
            }
            
        }
    }
}
